package com.example.adapter_sdk.quick;

import androidx.recyclerview.widget.DiffUtil;

import java.util.List;

public class BaseQuickDiff<T> extends DiffUtil.Callback {
    private List<T> sourceData;
    private List<T> nowData;
    public BaseQuickDiff(List<T> sourceData, List<T> nowData) {
        this.sourceData = sourceData;
        this.nowData = nowData;
    }

    @Override
    public int getOldListSize() {
        return sourceData.size();
    }

    @Override
    public int getNewListSize() {
        return nowData.size();
    }

    @Override
    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
        boolean flag = sourceData.get(oldItemPosition) == nowData.get(newItemPosition);
        return flag;
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
        return sourceData.get(oldItemPosition).toString().equals(nowData.get(oldItemPosition).toString());
    }
}
